﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

using SpiritAlight.SceneManagement;
using SpiritAlight.Character;

namespace SpiritAlight.SceneCreate
{
    class GameMain : Scene
    {
        private CharacterManager unitManager;
        /// <summary>
        /// ゲームメインコンストラクタ。
        /// </summary>
        /// <param name="Manager">シーンの所属するマネージャー。</param>
        /// <param name="State">初期化されるシーンの状態</param>
        public GameMain(SceneManager Manager, SceneState State)
            : base(Manager, State)
        {
            Initialize();
            LoadContents();
            
        }

        /// <summary>
        /// 初期化メソッド。
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();


            base.onFocus = () =>
            {
                ;
            };

            unitManager = new CharacterManager(this);
            unitManager.Initialize();
        }

        /// <summary>
        /// リソース読み込みメソッド。
        /// </summary>
        public override void LoadContents()
        {
            base.LoadContents();

            unitManager.LoadContent(base.SceneManager.Content);
        }

        /// <summary>
        /// 更新メソッド。
        /// </summary>
        public override void Update()
        {
            base.Update();

            unitManager.Update();

            if (base.SceneManager.InputState[Keys.Enter] == Input.DeviceState.Pressed)
            {
                if (NowState == SceneState.Active)
                {
                    base.TransOff();
                }

                if (NowState == SceneState.Hidden)
                {
                    base.TransOn();
                }
                
            }
        }

        /// <summary>
        /// 描画メソッド
        /// </summary>
        public override void Draw()
        {
            base.Draw();

            unitManager.Draw(base.SceneManager.SpriteBatch);
        }
    }
}
